def move_monster(game, monster, dest):
    if dest and dest.monster:
        raise MoveError('cannot move monster to occupied destination')
    if monster.env:
        monster.env.monster = None
    monster.env = dest
    if monster.env:
        monster.env.monster = monster


def move_item(game, item, dest):
    if item.env:
        item.env.remove_item(item)
    item.env = dest
    if item.env:
        item.env.add_item(item)


class MoveError(Exception):
    pass
